package com.changcheng.project.apppublishlog.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.apppublishlog.domain.AAppPublishLog;
import com.changcheng.project.apppublishlog.service.IAAppPublishLogService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * obu发布记录Controller
 * 
 * @author dazhi
 * @date 2020-10-31
 */
@Controller
@RequestMapping("/apppublishlog/apppublishlog")
public class AAppPublishLogController extends BaseController
{
    private String prefix = "apppublishlog/apppublishlog";

    @Autowired
    private IAAppPublishLogService aAppPublishLogService;

    @RequiresPermissions("apppublishlog:apppublishlog:view")
    @GetMapping()
    public String apppublishlog()
    {
        return prefix + "/apppublishlog";
    }

    /**
     * 查询obu发布记录列表
     */
    @RequiresPermissions("apppublishlog:apppublishlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AAppPublishLog aAppPublishLog)
    {
        startPage();
        List<AAppPublishLog> list = aAppPublishLogService.selectAAppPublishLogList(aAppPublishLog);
        return getDataTable(list);
    }

    /**
     * 导出obu发布记录列表
     */
    @RequiresPermissions("apppublishlog:apppublishlog:export")
    @Log(title = "obu发布记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AAppPublishLog aAppPublishLog)
    {
        List<AAppPublishLog> list = aAppPublishLogService.selectAAppPublishLogList(aAppPublishLog);
        ExcelUtil<AAppPublishLog> util = new ExcelUtil<AAppPublishLog>(AAppPublishLog.class);
        return util.exportExcel(list, "apppublishlog");
    }

    /**
     * 新增obu发布记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存obu发布记录
     */
    @RequiresPermissions("apppublishlog:apppublishlog:add")
    @Log(title = "obu发布记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AAppPublishLog aAppPublishLog)
    {
        return toAjax(aAppPublishLogService.insertAAppPublishLog(aAppPublishLog));
    }

    /**
     * 修改obu发布记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AAppPublishLog aAppPublishLog = aAppPublishLogService.selectAAppPublishLogById(id);
        mmap.put("aAppPublishLog", aAppPublishLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存obu发布记录
     */
    @RequiresPermissions("apppublishlog:apppublishlog:edit")
    @Log(title = "obu发布记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AAppPublishLog aAppPublishLog)
    {
        return toAjax(aAppPublishLogService.updateAAppPublishLog(aAppPublishLog));
    }

    /**
     * 删除obu发布记录
     */
    @RequiresPermissions("apppublishlog:apppublishlog:remove")
    @Log(title = "obu发布记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aAppPublishLogService.deleteAAppPublishLogByIds(ids));
    }
}
